Eclipse Platform
Pre-release 3.0

org.eclipse.jface.action
Class ToolBarContributionItem

java.lang.Object
  extended byorg.eclipse.jface.action.ContributionItem
      extended byorg.eclipse.jface.action.ToolBarContributionItem
All Implemented Interfaces:
IContributionItem

public class ToolBarContributionItem
extends ContributionItem

The ToolBarContributionItem class provides a wrapper for tool bar managers when used in cool bar managers. It extends ContributionItem but and provides some additional methods to customize the size of the cool item and to retrieve the underlying tool bar manager.

This class may be instantiated; it is not intended to be subclassed.

Since:
3.0

Field Summary
static int SHOW_ALL_ITEMS
          A constant used by setMinimumItemsToShow and getMinimumItemsToShow to indicate that all tool items should be shown in the cool item.
 
Constructor Summary
ToolBarContributionItem()
          Convenience method equivalent to ToolBarContributionItem(new ToolBarManager(), null).
ToolBarContributionItem(IToolBarManager toolBarManager)
          Convenience method equivalent to ToolBarContributionItem(toolBarManager, null).
ToolBarContributionItem(IToolBarManager toolBarManager, String id)
          Creates a tool bar contribution item.
 
Method Summary
 void dispose()
          The default implementation of this IContributionItem method does nothing.
 void fill(CoolBar coolBar, int index)
          The default implementation of this IContributionItem method does nothing.
 int getCurrentHeight()
          Returns the current height of the corresponding cool item.
 int getCurrentWidth()
          Returns the current width of the corresponding cool item.
 int getMinimumItemsToShow()
          Returns the minimum number of tool items to show in the cool item.
 IToolBarManager getToolBarManager()
          Returns the internal tool bar manager of the contribution item.
 boolean getUseChevron()
          Returns whether chevron support is enabled.
 void saveWidgetState()
          The default implementation of this IContributionItem method does nothing.
 void setCurrentHeight(int currentHeight)
          Sets the current height of the cool item.
 void setCurrentWidth(int currentWidth)
          Sets the current width of the cool item.
 void setMinimumItemsToShow(int minimumItemsToShow)
          Sets the minimum number of tool items to show in the cool item.
 void setUseChevron(boolean value)
          Enables or disables chevron support for the cool item.
 void update(String propertyName)
          The ContributionItem implementation of this method declared on IContributionItem does nothing.
 void updateSize(boolean changeCurrentSize)
          Updates the cool items' preferred, minimum, and current size.
 
Methods inherited from class org.eclipse.jface.action.ContributionItem
fill, fill, fill, getId, getParent, isDirty, isDynamic, isEnabled, isGroupMarker, isSeparator, isVisible, setParent, setVisible, toString, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SHOW_ALL_ITEMS

public static final int SHOW_ALL_ITEMS
A constant used by setMinimumItemsToShow and getMinimumItemsToShow to indicate that all tool items should be shown in the cool item.

See Also:
Constant Field Values
Constructor Detail

ToolBarContributionItem

public ToolBarContributionItem(IToolBarManager toolBarManager,
                               String id)
Creates a tool bar contribution item.

Parameters:
toolBarManager - the tool bar manager to wrap
id - the contribution item id, or null if none

ToolBarContributionItem

public ToolBarContributionItem(IToolBarManager toolBarManager)
Convenience method equivalent to ToolBarContributionItem(toolBarManager, null).

Parameters:
toolBarManager - the tool bar manager

ToolBarContributionItem

public ToolBarContributionItem()
Convenience method equivalent to ToolBarContributionItem(new ToolBarManager(), null).

Method Detail

getToolBarManager

public IToolBarManager getToolBarManager()
Returns the internal tool bar manager of the contribution item.

Returns:
the tool bar manager, or null if one is not defined.
See Also:
IToolBarManager

fill

public void fill(CoolBar coolBar,
                 int index)
Description copied from class: ContributionItem
The default implementation of this IContributionItem method does nothing. Subclasses may override.

Specified by:
fill in interface IContributionItem
Overrides:
fill in class ContributionItem

saveWidgetState

public void saveWidgetState()
Description copied from class: ContributionItem
The default implementation of this IContributionItem method does nothing. Subclasses may override.

Specified by:
saveWidgetState in interface IContributionItem
Overrides:
saveWidgetState in class ContributionItem

dispose

public void dispose()
Description copied from class: ContributionItem
The default implementation of this IContributionItem method does nothing. Subclasses may override.

Specified by:
dispose in interface IContributionItem
Overrides:
dispose in class ContributionItem

updateSize

public void updateSize(boolean changeCurrentSize)
Updates the cool items' preferred, minimum, and current size. The preferred size is calculated based on the tool bar size and extra trim.

Parameters:
changeCurrentSize - true if the current size should be changed to the preferred size, false to not change the current size

update

public void update(String propertyName)
Description copied from class: ContributionItem
The ContributionItem implementation of this method declared on IContributionItem does nothing. Subclasses should override to update their state.

Specified by:
update in interface IContributionItem
Overrides:
update in class ContributionItem

getMinimumItemsToShow

public int getMinimumItemsToShow()
Returns the minimum number of tool items to show in the cool item.

Returns:
the minimum number of tool items to show, or SHOW_ALL_ITEMS if a value was not set
See Also:
setMinimumItemsToShow(int)

setMinimumItemsToShow

public void setMinimumItemsToShow(int minimumItemsToShow)
Sets the minimum number of tool items to show in the cool item. If this number is less than the total tool items, a chevron will appear and the hidden tool items appear in a drop down menu. By default, all the tool items are shown in the cool item.

Parameters:
minimumItemsToShow - the minimum number of tool items to show.
See Also:
getMinimumItemsToShow(), setUseChevron(boolean)

setUseChevron

public void setUseChevron(boolean value)
Enables or disables chevron support for the cool item. By default, chevron support is enabled.

Parameters:
value - true to enable chevron support, false otherwise.

getUseChevron

public boolean getUseChevron()
Returns whether chevron support is enabled.

Returns:
true if chevron support is enabled, false otherwise

getCurrentWidth

public int getCurrentWidth()
Returns the current width of the corresponding cool item.

Returns:
the current size

getCurrentHeight

public int getCurrentHeight()
Returns the current height of the corresponding cool item.

Returns:
the current height

setCurrentHeight

public void setCurrentHeight(int currentHeight)
Sets the current height of the cool item. Update(SIZE) should be called to adjust the widget.

Parameters:
currentHeight - the current height to set

setCurrentWidth

public void setCurrentWidth(int currentWidth)
Sets the current width of the cool item. Update(SIZE) should be called to adjust the widget.

Parameters:
currentWidth - the current width to set

Eclipse Platform
Pre-release 3.0

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.